{% extends 'base.html' %}

{% block title %}任务列表{% endblock %}

{% block content %}
<div class="card">
    <div class="card-header bg-success text-white">
        <h5>任务列表</h5>
    </div>
    <div class="card-body">
        <form class="mb-4">
            <div class="row g-3">
                <div class="col-md-3">
                    <select class="form-select" name="status">
                        <option value="">全部状态</option>
                        <option value="暂存">暂存</option>
                        <option value="已发布">已发布</option>
                    </select>
                </div>
                <div class="col-md-3">
                    <select class="form-select" name="platform">
                        <option value="">全部平台</option>
                        {% for platform in platforms %}
                        <option value="{{ platform.id }}">{{ platform.name }}</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="col-md-3">
                    <select class="form-select" name="style">
                        <option value="">全部风格</option>
                        {% for style in styles %}
                        <option value="{{ style.id }}">{{ style.style_name }}</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="col-md-3">
                    <button type="submit" class="btn btn-primary w-100">筛选</button>
                </div>
            </div>
        </form>

        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>主题</th>
                        <th>发布平台</th>
                        <th>文案风格</th>
                        <th>字数</th>
                        <th>状态</th>
                        <th>创建时间</th>
                    </tr>
                </thead>
                <tbody>
                    {% for task in tasks %}
                    <tr>
                        <td>{{ task.title }}</td>
                        <td>{{ task.platform.name }}</td>
                        <td>{{ task.style.style_name }}</td>
                        <td>{{ task.word_count or '-' }}</td>
                        <td><span class="badge bg-{{ 'success' if task.status == '已发布' else 'warning' }}">{{ task.status }}</span></td>
                        <td>{{ task.create_time.strftime('%Y-%m-%d %H:%M') }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}